package com.gem.growingtree.activity;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;  
import android.widget.AdapterView;  
import android.widget.AdapterView.OnItemSelectedListener;  
import android.widget.ArrayAdapter;  
import android.widget.Spinner;  

public class MyInformationActivity extends Activity {
	
	private static final String[] m={"男","女"};
    private Spinner spinner;  
    private ArrayAdapter<String> adapter;
	private String sex;
    
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_information);
		
		spinner = (Spinner) findViewById(R.id.sex);
		
		//将可选内容与ArrayAdapter连接起来  
        adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,m);
        
        //设置下拉列表的风格  
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
       
        //将adapter 添加到spinner中  
        spinner.setAdapter(adapter);
        
        //添加事件Spinner事件监听    
//        spinner.setOnItemSelectedListener(new SpinnerSelectedListener());
        
        //设置默认值  
        spinner.setVisibility(View.VISIBLE);
	}
	
    //使用数组形式操作  
    class SpinnerSelectedListener implements OnItemSelectedListener{  
  
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,  
                long arg3) {  
        	sex=arg0.getItemAtPosition(arg2).toString();  
        }  
  
        public void onNothingSelected(AdapterView<?> arg0) {  
        }  
    } 


}
